package com.yb.guigu.pick.mqbackup.config;

import com.yb.guigu.pick.core.constant.RabbitMQConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/6/11 20:45
 * FileName: RabbitMQConfig
 * Description:
 */

@Configuration
public class RabbitMQConfig {

    @Configuration
    public static class EmailQueueConfig{

        @Bean
        Queue backupMQQueue(){
            return QueueBuilder.durable(RabbitMQConstant.BackupMQQueueConstant.QUEUE).build();
        }

        @Bean
        Exchange backupMQExchange(){
            return ExchangeBuilder.directExchange(RabbitMQConstant.BackupMQQueueConstant.EXCHANGE).durable(true).build();
        }

        @Bean
        Binding backupMQBinder(){
            return BindingBuilder.bind(backupMQQueue()).to(backupMQExchange()).with(RabbitMQConstant.BackupMQQueueConstant.ROUTING_KEY).noargs();
        }
    }

}
